// at895cc 驱动共阳极7段线数码管 静态显示 (7seg-com-anode)
#include <reg52.h>

// 定义共阳极7段数码管0-9的段码
unsigned char number_code[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
// a-f段码
unsigned char zimu_code[] = {0x08,0x03,0x46,0x21,0x06,0x0e};
void show_zumu(unsigned char zimu)
{
    if(zimu == 'a')
    {
        P0 = zimu_code[0];
    }
    else if(zimu == 'b')
    {
        P0 = zimu_code[1];
    }
    else if(zimu == 'c')
    {
        P0 = zimu_code[2];
    }
    else if(zimu == 'd')
    {
        P0 = zimu_code[3];
    }
    else if(zimu == 'e')
    {
        P0 = zimu_code[4];
    }
    else if(zimu == 'f')
    {
        P0 = zimu_code[5];
    }
}
void show_number(int number)
{
    P0 = number_code[number];
}
void delay(unsigned int ms) {
    unsigned int i, j;
    for (i = 0; i < ms; i++) {
        for (j = 0; j < 120; j++);  // 调整这个值可以改变延时的精度
    }
}
void dymatic_show_number()
{
  while(1)   
    {
        int i ;
        for(i=0;i<10;i++)   {
            show_number(i);
            delay(1000);
        }
    }
}
void dymatic_show_zimu()
{
while(1)   
    {
        int i ;
        for(i=0;i<6;i++)   {
            P0 = zimu_code[i];
            delay(1000);
        }
    }
}
void main()
{
    dymatic_show_number();
}